package org.example.baseproject.controller;

import org.example.baseproject.model.MessageInfo;
import org.example.baseproject.service.MessageInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/message")
public class MessageWallController {
    //存储留言信息
    @Autowired
    private MessageInfoService messageInfoService;

    @RequestMapping(value = "/publish",method = RequestMethod.POST)
    public Boolean publish(@RequestBody MessageInfo messageInfo) {
        //添加到数据库中
        messageInfoService.insertMessage(messageInfo);
        return true;
    }

    //获取留言信息
    @RequestMapping("/getList")
    public List<MessageInfo> getList() {
        //从数据库中查询
        return messageInfoService.queryMessage();
    }

}
